﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Common;

using Newtonsoft.Json;

namespace AdminUI.Controllers
{
    public class TemplateClassifyController : BaseController
    {
        // GET: TemplateClassify
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Add()
        {
            var data = HttpHelper.HttpGet<Result<List<Param_TemplateClassify>>>(Tools.ApiPath + "api/TemplateClassify/RootClass", "get");
            if (data.Code!=200)
            {
                return View("error");
            }
            return PartialView(data.Data);
        }

        public ActionResult Edit(int? id)
        {
            if (!id.HasValue)
            {
                return View("error");
            }

            var data = HttpHelper.HttpGet<Result<Param_TemplateClassify>>(Tools.ApiPath + "api/TemplateClassify/FindByID/" + id, "get");
            if (data.Code==200)
            {
                var cate = HttpHelper.HttpGet<Result<List<Param_TemplateClassify>>>(Tools.ApiPath + "api/TemplateClassify/ParentClass/" + id, "get").Data;
                ViewBag.Parent = cate;
                return PartialView(data.Data);
            }
            else
            {
                return View("error");
            }
        }
    }
}